package utils;


import uk.ac.nott.cs.g53dia.bee.Simulator;
import valueobj.SimulationSettings;

public class Simulation {
	private Simulator simulator;
	private static Simulation INSTANCE;
	private SimulationSettings settings;
	private volatile boolean started = false;
	
	private Simulation(){
		
	}
	
	public static synchronized Simulation getInstance() {
		if (INSTANCE == null) {
			INSTANCE = new Simulation();
		}
		return INSTANCE;
	}
	
	public static void pause () {
		getSimulator().pause();
	}
	
	public static Simulator getSimulator() {
		Simulator s = getInstance().getSim();
		if (s == null) {
			System.err.println("setup a simulator first.");
		}
		return s;
	}
	
	public static void setSimulator(Simulator simulator) {
		getInstance().setSim(simulator);
	}
	
	private Simulator getSim() {
		return simulator;
	}
	
	private void setSim(Simulator simulator) {
		this.simulator = simulator;
	}
	
	public static SimulationSettings getSettings() {
		SimulationSettings s = getInstance().getSet();
		if (s == null) {
			System.err.println("setup settings first.");
		}
		return s;
	}
	
	public static void setSettings(SimulationSettings settings) {
		getInstance().setSet(settings);
	}
	
	private SimulationSettings getSet() {
		return settings;
	}
	
	private void setSet(SimulationSettings settings) {
		this.settings = settings;
	}
	
	public static synchronized boolean isStarted() {
		return getInstance().isSt();
	}

	private boolean isSt() {
		return started;
	}
	
	public static synchronized void setStarted(boolean b) {
		getInstance().setSt(b);
	}

	private void setSt(boolean b) {
		started = b;
	}


}
